﻿package mortal.game.view.halidom.render
{
    import Message.Public.*;
    import com.gengine.utils.*;
    import com.mui.controls.*;
    import extend.language.*;
    import flash.events.*;
    import flash.geom.*;
    import mortal.common.global.*;
    import mortal.game.cache.*;
    import mortal.game.resource.*;
    import mortal.game.resource.info.*;
    import mortal.game.scene3D.ai.*;
    import mortal.game.scene3D.map3D.sceneInfo.*;
    import mortal.game.scene3D.map3D.util.*;
    import mortal.game.view.common.*;
    import mortal.game.view.halidom.*;

    public class HalidomWayFindingViewRenderer extends GCellRenderer
    {
        private var _name:GTextFiled;
        private var _tip:GTextFiled;
        private var _btnFlyBoot:GLoadedButton;
        private var _enterLv:int;

        public function HalidomWayFindingViewRenderer()
        {
            return;
        }// end function

        private function onClickName(event:TextEvent) : void
        {
            var _loc_2:SPassPoint = null;
            if (Cache.instance.role.entityInfo.level >= this._enterLv)
            {
                _loc_2 = HalidomUtil.getPoint(int(data));
                if (_loc_2)
                {
                    AIManager.onAIControl(AIType.GoToOtherMap, MapFileUtil.mapID, int(data), new Point(_loc_2.point.x, _loc_2.point.y));
                }
            }
            return;
        }// end function

        private function onClickFlyBoot(event:MouseEvent) : void
        {
            var _loc_2:SceneInfo = null;
            var _loc_3:int = 0;
            if (Cache.instance.role.entityInfo.level >= this._enterLv)
            {
                _loc_2 = SceneConfig.instance.getSceneInfo(int(data));
                if (_loc_2 && SPassPoint(_loc_2.passInfos[0]).passTo.length > 0)
                {
                    _loc_3 = SPassPoint(_loc_2.passInfos[0]).passTo.length;
                    AIManager.onAIControl(AIType.FlyBoot, SPassPoint(_loc_2.passInfos[0]).passTo[(_loc_3 - 1)]);
                }
            }
            return;
        }// end function

        override public function set data(param1:Object) : void
        {
            super.data = param1.data;
            var _loc_2:* = GameMapConfig.instance.getMapInfo(int(data));
            this._enterLv = HalidomUtil.getEnterLv(_loc_2.id);
            if (Cache.instance.role.entityInfo.level >= this._enterLv)
            {
                this._tip.htmlText = "";
                this._name.htmlText = HTMLUtil.addLink(_loc_2.name, GlobalStyle.colorLv);
            }
            else
            {
                this._tip.htmlText = HTMLUtil.addColor(Language.getStringByParam(70409, this._enterLv), GlobalStyle.colorLv);
                this._name.htmlText = HTMLUtil.addLink(_loc_2.name, GlobalStyle.colorHong);
            }
            this._btnFlyBoot.x = this._name.x + this._name.textWidth + 5;
            this._tip.x = this._btnFlyBoot.x + this._btnFlyBoot.width + 5;
            return;
        }// end function

        override public function set label(param1:String) : void
        {
            super.label = "";
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            pushUIToDisposeVec(UIFactory.bg(0, 0, 205, 25, this, ImagesConst.RegionTitleBg));
            this._name = UIFactory.gTextField("", 0, 0, 220, 20, this);
            this._tip = UIFactory.gTextField("", 90, 0, 100, 20, this);
            this._btnFlyBoot = UIFactory.gLoadedButton(ImagesConst.MapBtnFlyBoot_upSkin, 80, 2, 16, 18, this);
            this._name.configEventListener(TextEvent.LINK, this.onClickName);
            this._btnFlyBoot.configEventListener(MouseEvent.CLICK, this.onClickFlyBoot);
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl(param1);
            this._name.dispose(param1);
            this._tip.dispose(param1);
            this._btnFlyBoot.dispose(param1);
            return;
        }// end function

    }
}
